<%-- 
    Document   : accountingProductSales
    Created on : Feb 29, 2012, 12:52:21 PM
    Author     : Remy
--%>

<%@page import="Model.ACManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="../css/foo.css" type="text/css"/>
        <link rel="stylesheet" type="text/css" href="../css/superfish.css" media="screen">	
        <title>Foobar</title>
        <script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="../js/hoverIntent.js"></script>
        <script type="text/javascript" src="../js/superfish.js"></script>
        <script type="text/javascript">

            // initialise plugins
            jQuery(function(){
                jQuery('ul.sf-menu').superfish();
            });
            
            function checkAuth(){
              if(<%=request.getParameter("loginAttempt")%> == false){
                 document.write('<span class="errLog">Authentication failed.</span>');
               }
         }

        </script>
    </head>
    <body class="bg">
        <% if(request.getSession(true).getAttribute("username") == null){ response.sendRedirect("../login.jsp"); } %>
          <script type="text/javascript">checkAuth();</script>
        <br/>
        <div class="hmenu">
            <% if (request.getSession(true).getAttribute("username") == null) {%>
           <p style="font-size: 12px; margin-top: -15px; float: right;">If you're not yet a member, sign up <a href="../signUp.jsp">here!</a> </p>   
           <% }%>
           <img src="../images/head.png" style="float: left; margin-left:20px;"/>
            <div class="log">
                <% if (request.getSession(true).getAttribute("username") != null) {%>
                <h3>Welcome <%=session.getAttribute("username")%>!</h3>
                <br/>
<!--                insert stuff-->
                <a href="../LogoutServlet">Log out</a>
                <br/>
                <br/>
                <br/>
                <br/>
                <br/>
                 <p style="font-size: 10px; margin-top: -15px; float: right;">Click 
                    <a href="../managerpages/changeMPassword.jsp">here</a> to change your password.</p>
                <% } else { %>
                <span style="font-weight: bold;">Log in</span>
                <form method="post" action="../LoginServlet">
                    <label>Username:</label><input type="text" name="username"/><br/>
                    <label>Password:</label><input type="password" name="password"/><br/>
                    <input type="submit" value="Log in" name="submit"/>
                </form>
                <% }%>
            </div>
                <% if (request.getSession(true).getAttribute("username") != null && Integer.parseInt(request.getSession(true).getAttribute("acctype").toString()) == 7){ %>
            <ul class="sf-menu">
                  <li>
                    <a href="accountingManager.jsp">Home</a>
                </li>
                <li>
                    <a href="accountingTotalSales.jsp">Total Sales</a>
                </li>
                <li>
                    <a href="accountingProductSales.jsp">Sales per Product</a>
                </li>
                <li class="current">
                    <a href="accountingTypeSales.jsp">Sales per Product Type</a>
                </li>
            </ul>
            <%  }else{ %>
             <ul class="sf-menu">
                <li class="current">
                    <a href="index.jsp">Home</a>
                </li>
                <li>
                    <a href="#">Products</a>
                    <ul>
                        <li>
                            <a href="#">Book</a>
                        </li>
                        <li>
                            <a href="#">Magazine</a>
                        </li>
                        <li>
                            <a href="#">Audio CD</a>
                        </li>
                        <li>
                            <a href="#">DVD</a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#">Stores</a>
                </li>
                <li>
                    <a href="#">Contact Us</a>
                </li>
                <li>
                    <a>SEARCH FUNCTION HERE</a>
                </li>
            </ul>
             <% } %>
        </div>
        <div class="content">
                <% if (request.getSession(true).getAttribute("username") != null && Integer.parseInt(request.getSession(true).getAttribute("acctype").toString()) == 7){ %>
            <b>Welcome to Foobar</b>
            <br/>
            Online bookstore made available for you!<br/>
            <hr /> 
           <table>
                <tr><td>
                <%
                    try {

                        ResultSet prj = new ACManager().productTypeSales();

                %>
                <table width="800px" cellspacing="0px" margin="0px" cellpadding="0px" align="left" style="margin-top:20px;">
                    <% while (prj.next()) {%>
                    <tr>
                        <td valign="top"><label>Type: </label><span><%=prj.getString("pt.ProductType")%> </span><br />
                            <label>Quantity: </label><span><%=prj.getInt("Quantity")%></span><br/>
                            <label>Sales: </label><span><%=prj.getInt("Sales")%></span><br/>
                            <hr/>
                        </td>
                    </tr>
                    <% }%>
                </table>
                <%
                prj.close();
                    } catch (Exception ex) {
                        ex.printStackTrace();
                        
                    }
                %>
            <br/>
            </td></tr></table>
                <br/>
            
            <% } else { %>
            <h1>Oops! We don't think you're allowed to be here.</h1>
            <span>Please log in with the correct user credentials</span>
            <% } %>
        </div>
    </body>
</html>